package com.situ.mall.service.Impl;

import com.situ.mall.mapper.UserMapper;
import com.situ.mall.pojo.entity.User;
import com.situ.mall.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements IUserService {
    @Autowired
    private UserMapper userMapper;
    @Override
    public User login(String account, String password) {
        return userMapper.login(account, password);
    }

    @Override
    public User selectByInfoId(Integer id) {
        return userMapper.selectByPrimaryKey(id);
    }

    @Override
    public void updateInfo(User user) {
        userMapper.updateByPrimaryKeySelective(user);
    }

    @Override
    public void updatePassword(Integer id, String newPassword) {
        User user = new User();
        user.setId(id);
        user.setPassword(newPassword);
        userMapper.updateByPrimaryKeySelective(user);
    }

    @Override
    public Integer selectByAccount(User user) {
        return userMapper.selectByAccount(user);
    }

    @Override
    public void register(User user) {
        userMapper.insertSelective(user);
    }

    @Override
    public Integer selectByAccountId(User user) {
        return userMapper.selectByAccountId(user);
    }

    @Override
    public Integer selectByAccountPhone(User user) {
        return userMapper.selectByAccountPhone(user);
    }

    @Override
    public void forget(User user) {
        userMapper.forget(user);
    }
}
